package br.com.wagnerpaz.javahook.system;

public class SystemInfo
{
	private static final String OSID_LINUX = "nux";
	private static final String OSID_UNIX  = "nix";
	private static final String OSID_MAC   = "mac";
	private static final String OSID_WIN   = "win";
	
	public static OSType getOSType()
		throws UnsupportedOperationalSystem
	{
		if (isWindows())
		{
			return OSType.WINDOWS;
		}
		else if (isUnix())
		{
			return OSType.LINUX;
		}
		else if (isMac())
		{
			return OSType.MAC;
		}
		else
		{
			throw new UnsupportedOperationalSystem();
		}
	}

	private static boolean isWindows()
	{
		String os = System.getProperty("os.name").toLowerCase();
		return (os.indexOf(OSID_WIN) >= 0);
	}

	private static boolean isMac()
	{
		String os = System.getProperty("os.name").toLowerCase();
		return (os.indexOf(OSID_MAC) >= 0);
	}

	private static boolean isUnix()
	{
		String os = System.getProperty("os.name").toLowerCase();
		return (os.indexOf(OSID_UNIX) >= 0 || os.indexOf(OSID_LINUX) >= 0);
	}
}